< previous page page_75 next page >

Page 75
Puzzle 17
The DEVMODE Is in the Details
The Win32API.txt file provided with visual studio includes the following declaration for the DocumentProperties function:
Declare Function DocumentProperties Lib "winspool.drv" Alias _
"DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, _
ByVal pDeviceName As String, pDevModeOutput As DEVMODE, _
pDevModeInput As DEVMODE, ByVal fMode As Long) As Long
My Win32 API book defines it as follows:
Declare Function DocumentProperties Lib "winspool.drv" Alias _
"DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, _
ByVal pDeviceName As String, ByVal pDevModeOutput As Long, ByVal _
pDevModeInput As Long, ByVal fMode As Long) As Long
where both pDevModeOutput and pDevModeInput are defined as pointers to DEVMODE data structures.
The C declaration is as follows:
LONG DocumentProperties(
    HWND hWnd, // handle to window that displays dialog box
    HANDLE hPrinter, // handle to printer object
    LPTSTR pDeviceName, // pointer to device name
    PDEVMODE pDevModeOutput, // pointer to modified device mode
                                 // structure
    PDEVMODE pDevModeInput, // pointer to original device mode structure
    DWORD fMode  // mode flag
   );
If you've read Tutorial 4, ''How DLL Calls Work: Inside a Stack Frame," you know that declaring the parameter As DEVMODE (as shown in win32api.txt) will, in fact, pass a pointer to a DEVMODE structure. Why would the declaration in

 
< previous page page_75 next page >